import request from "@/utils/request";
import {c} from "vite/dist/node/types.d-aGj9QkWt";

enum UserApi {
    // 登录
    LOGIN = "/users/login",
    // 注册
    REGISTER = "/users/register",
    // 获取用户信息
    GET_USER_INFO = "/users/findByName",
    // 修改用户信息
    UPDATE_USER_INFO = "/user/update",
}

export const login = (data: any) => {
    console.log("/users/login", data);
    const parmas = new URLSearchParams();
    for (let key in data) {
        parmas.append(key, data[key]);
    }
    return request({
        url: UserApi.LOGIN,
        method: "post",
        data: parmas
    });
}
export const register = (data: any) => {
    console.log("/users/login", data);
    const parmas = new URLSearchParams();
    for (let key in data) {
        parmas.append(key, data[key]);
    }
    return request({
        url: UserApi.REGISTER,
        method: "post",
        data: parmas
    });
}
export const getUserInfo = (username: string) => {
    return request({
        url: UserApi.GET_USER_INFO + "/" + username,
        method: "get",
    });
}
export const updateUserInfo = (data: any) => {
    return request({
        url: UserApi.UPDATE_USER_INFO,
        method: "post",
        data
    });
}
